<!--suppress ALL -->
<template>
  <div class="block">
    <el-pagination
      background
      layout="prev, pager, next"
      @current-change="handleCurrentChange"
      :total=100>
    </el-pagination>
  </div>
</template>


<script type="text/javascript">
  import axios from 'axios'

  export default {
    props: ['context'],
    methods: {
      //单前页数发生变化，默认是一章一页
      handleCurrentChange(val) {
        var novelName = window.localStorage.getItem("novelName");
        var chapterName = "第" + val + "章";
        var _this = this;
        axios.get('http://localhost:8081/findByChapterName?novelName=' + novelName + '&chapterName=' + chapterName)
          .then(function (response) {
            var data = response.data;
            _this.$emit("changeContext", data.chapterContext, null, null);
          }).catch(function (response) {
          console.log(response);
        });
      }
    },
    data() {
      return {
        currentPage: 4
      };
    }
  }
</script>
